import 'dart:convert';

class UserMessages {
  String? profilePicture;
  String? userName;
  String? lastMessage;
  String? dateNow;

  UserMessages(
      {this.profilePicture, this.userName, this.lastMessage, this.dateNow});

  UserMessages copyWith({
    String? profilePicture,
    String? userName,
    String? lastMessage,
    String? dateNow,
  }) {
    return UserMessages(
        profilePicture: profilePicture ?? profilePicture,
        userName: userName ?? userName,
        lastMessage: lastMessage ?? lastMessage,
        dateNow: dateNow ?? dateNow);
  }

  Map<String, dynamic> toMap() {
    return {
      'profilePicture': profilePicture,
      'userName': userName,
      'lastMessage': lastMessage,
      'dateNow': dateNow
    };
  }

  factory UserMessages.fromMap(Map<String, dynamic> map) {
    return UserMessages(
      profilePicture: map['profilePicture'],
      userName: map['userName'],
      lastMessage: map['lastMessage'],
      dateNow: map['dateNow'],
    );
  }

  String toJson() => json.encode(toMap());

  UserMessages.fromJson(Map<String, dynamic> json) {
    profilePicture = json['profilePicture'];
    userName = json['userName'];
    lastMessage = json['lastMessage'];
    dateNow = json['dateNow'];
  }

  @override
  String toString() =>
      'UserMessages{profilePicture: $profilePicture, userName: $userName, lastMessage: $lastMessage, dateNow: $dateNow}';

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is UserMessages &&
          runtimeType == other.runtimeType &&
          profilePicture == other.profilePicture &&
          userName == other.userName &&
          lastMessage == other.lastMessage &&
          dateNow == other.dateNow;

  @override
  int get hashCode =>
      profilePicture.hashCode ^
      userName.hashCode ^
      lastMessage.hashCode ^
      dateNow.hashCode;
}
